function totalTravel(vel_i,vel_f,t,dist,a)
%totalTravel(vel_i,vel_f,dist,a)
%   Vel_i: Starting speed of planet
%	Vel_f: Speed of destination
%	t: Time spend for accel/deceleration (seconds)
%	Dist: Disance to cover (in AU)
%	a: Acceleration to use (Gs)

%% Convert to SI
a=a*9.80665;
dist=dist*150e9;

%% Calculate Departure
dv_a=a*t; % Velocity gained from burn (m/s)
cD_a=vel_i*t+.5*a*t^2; % Distance traveled from burn (m)

%% Calculate Arrival
dv_d=dv_a+vel_i-vel_f;
t_d=dv_d/a;
cD_d=(vel_i+dv_a)*t_d+.5*a*t_d^2;

%% Calculate Cruise
cD_r=dist-cD_a-cD_d;
if(sign(cD_r)==-1) %#ok<MFAMB>
	fprintf('Accel Dist: %f\n',cD_a); %#ok<MFAMB>
	fprintf('Decel Dist: %f\n',cD_d);
	fprintf('Total Dist: %f\n',dist);
	error('Accel and Deccel phases overlap, need more acceleration!\n'); %#ok<MFAMB>
end
cT=cD_r/(vel_i+dv_a)+t+t_d;
	fprintf('\nTotal travel time:\n');  
if(mod(cT,60)) %#ok<MFAMB>
	fprintf('                   %.1f s\n',mod(cT,60));
	cT=cT-mod(cT,60);
end
cT=cT/60; % Convert to minutes

if(mod(cT,60))
	fprintf('                   %.1f min\n',mod(cT,60));
	cT=cT-mod(cT,60);
end
cT=cT/60; % Convert to hours

if(mod(cT,24))
	fprintf('                   %.1f hours\n',mod(cT,24));
	cT=cT-mod(cT,24);
end
cT=cT/24; % Convert to days

if(mod(cT,365))
	fprintf('                   %.1f days\n',mod(cT,365));
	cT=cT-mod(cT,365);
end

cT=cT/365;

if(cT)
	fprintf('                   %.1f years\n',cT);
end

fprintf('Travel Stats:\n');
fprintf('   Departure Velocity: %.2f (m/s)\n',vel_i+dv_a);
fprintf('   Arrival Velocity: %.2f (m/s)\n',vel_f+abs(dv_d)); %#ok<MFAMB>

fprintf('Cost of travel:\n');
fprintf('   Acceleration: %.2f (m/s)\n',abs(dv_a));
fprintf('   Deceleration: %.2f (m/s)\n',abs(dv_d));
fprintf('   Total DV used: %.2f (m/s)\n',abs(dv_d)+abs(dv_a));


end

